Skip to content

feat: add bunny preset#4025

Open
sandros94 wants to merge 14 commits intonitrojs:mainfrom
sandros94:feat/bunny-preset
Open

feat: add bunny preset#4025
sandros94 wants to merge 14 commits intonitrojs:mainfrom
sandros94:feat/bunny-preset

Conversation

@sandros94
Copy link
Copy Markdown
Contributor

@sandros94 sandros94 commented Feb 11, 2026

🔗 Linked issue

Discussed privately

❓ Type of change

  • 📖 Documentation (updates to the documentation, readme, or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

This is an experimental preset to be used on Bunny.net Edge Scripting.

The serverless platform is built ontop of Deno, with accessible pricing and ease of use, but it does come at the cost of some challanging limitations (single-file bundle artifact, 10MB max; 500ms max startup; 128MB memory; etc.), nothing that Nitro is not currently able to handle.

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@sandros94 sandros94 requested a review from pi0 as a code owner February 11, 2026 18:04
@vercel
Copy link
Copy Markdown

vercel Bot commented Feb 11, 2026

@sandros94 is attempting to deploy a commit to the Nitro Team on Vercel.

A member of the Team first needs to authorize it.

@sandros94
Copy link
Copy Markdown
Contributor Author

Typecheck should be failing because of d3b1f7b

@sandros94 sandros94 marked this pull request as draft February 11, 2026 18:14
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 11, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds a new Bunny edge-scripting preset: registers the preset and types, implements the preset module and Deno runtime entry, and adds tests and test helper updates to validate build output and runtime behavior.

Changes

Cohort / File(s) Summary
Preset Registry & Types
src/presets/_all.gen.ts, src/presets/_types.gen.ts
Imported and spread ..._bunny into aggregated presets; extended PresetName and PresetNameInput with bunny, bunny-edge-scripting and alias variants.
Bunny Preset Module
src/presets/bunny/preset.ts
New edgeScripting preset via defineNitroPreset (entry bunny/runtime/edge-scripting), export conditions (including deno), preview command, output/layout, Rollup config, serveStatic enforcement hook, and compiled hook removing publicDir. Exported as default [edgeScripting] as const.
Bunny Runtime Entry
src/presets/bunny/runtime/edge-scripting.ts
New Deno runtime entry that boots a Bunny/Srvx server wired to Nitro's fetch, handles websocket upgrades when available, derives host/port from env, and starts scheduled tasks when enabled.
Tests & Test Helpers
test/presets/bunny.test.ts, test/tests.ts
Added bunny-edge-scripting preset test validating generated bunny-edge-scripting.mjs, inline/public assets behavior, and minification; updated test setup to classify bunny-edge-scripting as a worker and skip sourcemap test where appropriate.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat: add bunny preset' follows conventional commits format with 'feat:' prefix and clearly describes the main change of adding a new preset.
Description check ✅ Passed The description is directly related to the changeset, explaining the experimental Bunny.net Edge Scripting preset with relevant context about platform constraints and features.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sandros94 sandros94 marked this pull request as ready for review February 11, 2026 18:21
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@src/presets/bunny/runtime/edge-scripting.ts`:
- Around line 11-16: The preset for the bunny runtime is missing the unenv
configuration so process.env polyfills aren't injected; update the preset config
to include unenv: unenvDeno alongside exportConditions: ["deno"] so references
like process.env (used when computing _parsedPort and in the Deno.serve options)
are properly polyfilled at runtime. Locate the bunny runtime preset object that
currently sets exportConditions: ["deno"] (or similar) and add the unenv:
unenvDeno property to that same config.

In `@test/presets/bunny.test.ts`:
- Around line 16-29: The spawned Deno process from the execa(...) call is never
captured and therefore never killed; update the test to store the returned child
process (from execa(...)) into a variable (e.g., proc) and replace the no-op
ctx.server.close with a callback that terminates that process (e.g., proc.kill()
/ proc.kill("SIGKILL") or proc.cancel() per execa API) so the Deno process
running bunny-edge-scripting.mjs is reliably stopped when ctx.server.close() is
invoked; keep the same env/NITRO_PORT setup and use ctx.outDir to locate the
script as before.

Comment thread src/presets/bunny/runtime/edge-scripting.ts Outdated
Comment thread test/presets/bunny.test.ts Outdated
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Feb 13, 2026

Open in StackBlitz

npm i https://pkg.pr.new/nitro@4025

commit: fbd3edc

@pi0 pi0 changed the title feat(bunny): add new preset feat: add bunny preset Feb 17, 2026
fago added a commit to fago/nitro that referenced this pull request Mar 14, 2026
Backport of nitrojs#4025 to nitro v2.
Adapted imports and runtime to use v2 APIs (nitropack/runtime, localFetch).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@RihanArfan
Copy link
Copy Markdown
Member

Since Bunny is compatible with crossws, let's update mention Bunny here https://nitro.build/docs/websocket

@sandros94
Copy link
Copy Markdown
Contributor Author

sandros94 commented Apr 20, 2026

Since Bunny is compatible with crossws, let's update mention Bunny here https://nitro.build/docs/websocket

Sorry @RihanArfan, I didn't notice your message. I'm actually waiting a bit more on promoting ws on Bunny, as there currently is an upstream issue they have to fix (in some PoP ws connections get terminated prematurely).

For anyone curious here's the reproduction on which they validated the bug. Still no ETA tho ☹️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants